package com.cskaoyan.service;

import com.cskaoyan.bean.MarketOrderGoods;
import com.cskaoyan.bean.MarketOrderGoodsExample;
import com.cskaoyan.mapper.MarketOrderGoodsMapper;
import com.cskaoyan.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class OrderGoodsServiceImpl implements OrderGoodsService {
    @Override
    public  List<MarketOrderGoods> selectByExample(Integer id) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        MarketOrderGoodsMapper mapper = sqlSession.getMapper(MarketOrderGoodsMapper.class);
        MarketOrderGoodsExample example = new MarketOrderGoodsExample();
        MarketOrderGoodsExample.Criteria criteria = example.createCriteria();
        if (id!=null){
            criteria.andIdEqualTo(id);
        }
        List<MarketOrderGoods> marketOrderGoods = mapper.selectByExample(example);
        return marketOrderGoods;
    }

    @Override
    public Integer deleteByOrderId(Integer orderId,SqlSession sqlSession) {
        MarketOrderGoodsMapper mapper = sqlSession.getMapper(MarketOrderGoodsMapper.class);
        int i = mapper.deleteByOrderId(orderId);
        return i;
    }
}
